import {createRouter, createWebHistory} from 'vue-router'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Login from "@/views/Login/Login.vue";
import Customer from "@/views/Customer/index.vue";
import CustomerInfo from "@/views/Customer/components/CustomerInfo.vue";
import CustomerRepassword from "@/views/Customer/components/CustomerRepassword.vue";
import Detail from "@/views/Detail/index.vue";
import Search from "@/views/Search/index.vue";
import Shopcart from "@/views/Shopcart/index.vue"
import Order from '@/views/Order/index.vue'
import OrderSuccess from '@/views/Order/success.vue'
import CustomerOrder from '@/views/Customer/components/CustomerOrder.vue'
import Exchange from '@/views/Exchange/index.vue'

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/',
            component: Layout,
            children: [
                {path: '', component: Home},
                {path: 'detail/:id', component: Detail},
                {path: 'search/:keyword', component: Search, name: 1},
                {path: 'category/:keyword', component: Search, name: 2},
                {path: 'shopcar', component: Shopcart},
                {path: 'order', component: Order},
                {path: 'ordersuccess', component: OrderSuccess},
                {path: 'exchange', component: Exchange}
            ]
        },
        {
            path: '/login',
            component: Login
        },
        {
            path:'/customer',
            component: Customer,
            children: [
                {path: 'info', component: CustomerInfo},
                {path: 'repassword', component: CustomerRepassword},
                {path: 'order', component: CustomerOrder}
            ]
        }
    ],
    // 路由行为配置项
    scrollBehavior() {
        return {
            top: 0
        }
    }
})

export default router;
